enyo.kind({
	name: "enyo.Canon.FeedList",
	kind: enyo.VFlexBox,
	components: [
		{name: "getFeed", kind: "WebService",
			method: "POST",
            handleAs: "json",
            contentType: "application/x-www-form-urlencoded",
            headers: {"X-HP-SBS-ApplicationId": "sharedbusws1",
                "X-HP-SBS-ApplicationKey": "N3v3rsurr3nd3r",
                "X-HP-SBS-TestRequest": "false",
                "X-HP-SBS-SessionContext": "3999e3e6-782f-4354-85ed-7d43d3e0a4ff",
                "Accept": "application/json"
            },
			onSuccess: "gotFeed",
			onFailure: "gotFeedFailure"},
		{kind: "RowGroup", caption: "Feed URL", components: [
			{kind: "Input", value: "http://16.158.83.140:8080/analysis-1.0/retrieveAllListAnalysisType", components: [
				{kind: "Button", caption: "Get Feed", onclick: "btnClick"},
			]}
		]},
		{name: "list", kind: "VirtualList", flex: 1, onSetupRow: "listSetupRow", components: [
			{kind: "Item", layoutKind: "VFlexLayout", components: [
				{name: "title", kind: "Divider"},
				{name: "description", allowHtml: true}
			]}
		]},
	],
	create: function() {
		this.inherited(arguments);
		this.results = [];
	},
	btnClick: function() {
        var url = this.$.input.getValue();
        this.$.getFeed.setUrl(url);
        this.$.getFeed.call();
    },
	gotFeed: function(inSender, inResponse) {
        enyo.log(inResponse);
        this.results = inResponse.payload;
        this.$.list.refresh();
    },
	gotFeedFailure: function(inSender, inResponse) {
		console.log("got failure from getFeed");
	},
	listSetupRow: function(inSender, inRow) {
		var r = this.results[inRow];
		if (r) {
			this.$.title.setCaption(r.title);
			this.$.description.setContent(r.description);
			return true;
		}
	}	
});